Genesys CTI User Forum
Genesys CTI User Forum => Genesys-related Development => Topic started by: Rajnish@49 on December 31, 2022, 05:30:09 PM
-
Hello Everyone,
I am trying to Update a Backend System, After Agent send out email from WDE. I am using Custom Chain of Command InteractionEmailSend. I tried returning true and False both from custom command class. But in none of the case EMail is Sent out. When i hit send button, WDE remains in same Send Screen. In WDE Logs i can see command gets executed and completed.
22-12-31 21:33:12.193 [ 32] DEBUG cture.ChainOfCommand - Start Execution of Chain of Command InteractionEmailSend CommandParameter
22-12-31 21:33:12.194 [ 32] DEBUG cture.ChainOfCommand - Execute of Chain of Command InteractionEmailSend -> Name:After Send Email Type:Genesyslab.Desktop.Modules.InteractionExtensionSample.AfterSendEmail
22-12-31 21:33:12.206 [ 32] DEBUG cture.ChainOfCommand - Stop of Execution of Chain of Command 'InteractionEmailSend' by command 'After Send Email'
22-12-31 21:33:12.208 [ 32] INFO cture.ChainOfCommand - End of Execution of Chain of Command InteractionEmailSend ( 14.912 ms)
Please find below the code of CUstomcommand CLass and COmmand Activator.
commandManager.InsertCommandToChainOfCommandAfter("InteractionEmailSend", "Send",
new List<CommandActivator>() { new CommandActivator() {
CommandType = typeof(SendEmail), Name = "CaseReleaseCustomCommand"
}});
Custom Command:-
class SendEmail: IElementOfCommand
{
readonly IObjectContainer container;
ILogger log;
IInteractionManager interactionManager;
public INotepadViewModel notepadViewModel { get; }
public SendEmail(IObjectContainer container, IInteractionManager interactionManager, INotepadViewModel notepadViewModel)
{
this.container = container;
this.interactionManager = interactionManager;
this.notepadViewModel = notepadViewModel;
// Initialize the trace system
this.log = container.Resolve<ILogger>();
// Create a child trace section
this.log = log.CreateChildLogger("WDE Cust Debug:-- Send Email button clicked");
}
public string Name { get { return "Before Send Email"; } set { } }
public object Context { get; set; }
public bool Execute(IDictionary<string, object> parameters, IProgressUpdater progress)
{
// To go to the main thread
if (Application.Current.Dispatcher != null && !Application.Current.Dispatcher.CheckAccess())
{
object result = Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new ExecuteDelegate(Execute), parameters, progress);
return (bool)result;
}
else
{
// Ok, we are in the main thread
return true;
}
}
/// <summary>
/// This delegate allows to go to the main thread.
/// </summary>
delegate bool ExecuteDelegate(IDictionary<string, object> parameters, IProgressUpdater progressUpdater);
Please Help!!
Thanks,
Rajnish
-
Hello. Here are some thoughs that could help you.
On this:
[quote]
public string Name { get { return "Before Send Email"; } set { } }
[/quote]
I would replace with just:
[code]
public string Name { get ; set ; }
[/code]
Since the name is set on the Command Activator and it might be needed to be found in the execution Chain (not sure, though).
Not mandatory, but keep the Child Log name short, since the name is trimmed on the logs for the last few characters:
[quote]
this.log = log.CreateChildLogger("WDE Cust Debug:-- Send Email button clicked");
[b]change to something short that you can lookup later, like:[/b]
this.log = log.CreateChildLogger("WDECustDebug");
[/quote]
on the Execute method, insert something on the log just to see if it really firing your custom command:
[quote]
public bool Execute(IDictionary<string, object> parameters, IProgressUpdater progress)
{
[b]this.log.Error("Executing my custom SendEmail class");[/b]
// To go to the main thread
if (Application.Current.Dispatcher != null && !Application.Current.Dispatcher.CheckAccess())
{
object result = Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new ExecuteDelegate(Execute), parameters, progress);
return (bool)result;
[/quote]
and finally, return [b]false[/b] on your Execute method. Returning "true" means you should stop executing the next steps of the chain of command.
If it still doesn't work, try inserting your command at the beginning of the chain of commands, just to see if it runs - maybe another "Default" WDE command is stopping its execution:
[quote]
commandManager.CommandsByName["InteractionEmailSend"].Insert(0,
new CommandActivator() {
CommandType = typeof(SendEmail),
Name = "CaseReleaseCustomCommand"
}
);
[/quote]