Genesys CTI User Forum > Genesys-related Development

Create a Transfer button in IWS Customization

<< < (2/3) > >>

jvallejos:
Hello,
I used your code in my botton of my form

using Genesyslab.Desktop.Infrastructure;
using Genesyslab.Desktop.Infrastructure.Commands;
using Genesyslab.Desktop.Infrastructure.Configuration;
using Genesyslab.Desktop.Infrastructure.DependencyInjection;
using Genesyslab.Desktop.Infrastructure.ViewManager;
using Genesyslab.Desktop.Modules.Core.Model.Agents;
using Genesyslab.Desktop.Modules.Core.Model.Interactions;
using Genesyslab.Desktop.Modules.Windows.Event;
using Genesyslab.Desktop.Modules.Windows.IWMessageBox;
using Genesyslab.Enterprise.Commons.Collections;
using Genesyslab.Platform.Commons.Logging;
using Genesyslab.Platform.Voice.Protocols.TServer.Events;
using Microsoft.Practices.Composite.Events;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Windows;
using Genesyslab.Desktop.Modules.Voice.Model.Interactions;
using System.Windows.Threading;
using System.IO;


        private void btn_ITransferencia_Click(object sender, RoutedEventArgs e)
        {
            IDictionary<string, object> parameters = new Dictionary<string, object>();
            //parameters.Add("CommandParameter", IInteraction);
            IInteractionVoice interactionVoice = parameters["CommandParameter"] as IInteractionVoice;
            parameters.Add("CommandParameter", interactionVoice);
            parameters.Add("Destination", "31001000");
            parameters.Add("Location", "");
            parameters.Add("UserData", new KeyValueCollection());
            parameters.Add("Reasons", new KeyValueCollection());
            parameters.Add("Extensions", new KeyValueCollection());
            parameters.Add("CorrelatorData", "");
 
            container.Resolve<ICommandManager>().GetChainOfCommandByName("InteractionVoiceSingleStepTransfer").Execute(parameters);
        }

but the call not transfer and show me this error in the log of  WDE

16-11-07 23:41:56.488 [            1] ERROR .BootstrapController - Application.DispatcherUnhandledException
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
  at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
  at Genesyslab.Desktop.Modules.InteractionExtensionSample.MySample.MySampleView.btn_ITransferencia_Click(Object sender, RoutedEventArgs e)
  at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
  at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
  at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
  at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
  at System.Windows.Controls.Primitives.ButtonBase.OnClick()
  at System.Windows.Controls.Button.OnClick()
  at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
  at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
  at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
  at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
  at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
  at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
  at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
  at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
  at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
  at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
  at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
  at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
  at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
  at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
  at System.Windows.Input.InputManager.ProcessStagingArea()
  at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
  at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
  at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
  at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
  at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
  at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
  at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
  at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
  at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Please, what am I doing wrong? My WDE is version 8.5.110.16

Best regards

PeteHoyle:
The problem is that you create a Dictionary called parameters:

IDictionary<string, object> parameters = new Dictionary<string, object>();

And then without adding anything to the Dictionary you try and get an IInteractionVoice object with a key name of 'CommandParameter' from the Dictionary

IInteractionVoice interactionVoice = parameters["CommandParameter"] as IInteractionVoice;

And so you get an error that they key name does not exist.

You need to find another way to get the IInteractionVoice that you want to transfer.

daniel_san:
[quote author=PeteHoyle link=topic=8749.msg45115#msg45115 date=1478594394]
The problem is that you create a Dictionary called parameters:

IDictionary<string, object> parameters = new Dictionary<string, object>();

And then without adding anything to the Dictionary you try and get an IInteractionVoice object with a key name of 'CommandParameter' from the Dictionary

IInteractionVoice interactionVoice = parameters["CommandParameter"] as IInteractionVoice;

And so you get an error that they key name does not exist.

You need to find another way to get the IInteractionVoice that you want to transfer.
[/quote]

PeteHoyle explained you very well.

So, you have to get the IInteracionVoice. Try with InteractionManager...

container.Resolve<IInteractionManager>();

Regards.

jvallejos:
Hello PeteHoyle and daniel_san,
Please. Your  have other code to the transfer ?
Me Can sharing you please.
I used container.Resolve<IInteractionManager>(); but not know how I use this interface.

Best regards

daniel_san:
[quote author=jvallejos link=topic=8749.msg45132#msg45132 date=1478620751]
Hello PeteHoyle and daniel_san,
Please. Your  have other code to the transfer ?
Me Can sharing you please.
I used container.Resolve<IInteractionManager>(); but not know how I use this interface.

Best regards
[/quote]

To use the container you have to resolve  it on the contructor of the class.

You can see it on the documentation and examples.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version