Evenements dans un objet COM réalisé en c#

warenbe Messages postés 145 Date d'inscription dimanche 2 décembre 2001 Statut Membre Dernière intervention 10 septembre 2009 - 10 sept. 2009 à 09:07
warenbe Messages postés 145 Date d'inscription dimanche 2 décembre 2001 Statut Membre Dernière intervention 10 septembre 2009 - 10 sept. 2009 à 17:21
Bonjour,

je dois faire un objet COM à partir d'un dll .net que j'avais déjà réalisé
donc j'ai procédé comme suis:
creation d'un nouveau projet dans visual studio,
mise en reference de ma DLL .net

et ensuite j'ai fais le code ci dessous:

namespace NavisionComponent
{
    [ComVisible(true)]
    public interface INavisionCTI
    {
        void startMonitoring();
        void stopMonitoring();
        void showConfiguration();
        void dial(string number);
        void disconnect();  
        void answer(); 
        void blindTransfer(string numero);

    }

    [ComVisible(true)]
    [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    public interface INavisionCTIEvents
    {
        void onIncomingCall(string caller, string callee);
        void onOutgoingCall(string caller, string callee);
        void onConnected();
        void onDisconnected(int duration);
        
    }


    [ClassInterface(ClassInterfaceType.None)] 
    [ComSourceInterfaces(typeof(INavisionCTIEvents))]
    [ComVisible(true)]
    public class NavisionCTI: INavisionCTI
    {
        CTI cti;
        string ligne;

        public delegate void incomingCallHandler(string caller, string callee);
        public delegate void outgoingCallHandler(string caller, string callee);
        public delegate void connectedHandler();
        public delegate void disconnectedHandler(int duration);
        public event outgoingCallHandler onOutgoingCall;
        public event connectedHandler onConnected;
        public event incomingCallHandler onIncomingCall;
        public event disconnectedHandler onDisconnected;

        public NavisionCTI()
        {
            cti = new CTI();
            cti.onCallConnected += new CTI.CallConnectedEventHandler(cti_onCallConnected);
            cti.onCallDisconnected += new CTI.CallDisconnectedEventHandler(cti_onCallDisconnected);
            cti.onNewIncomingCall += new CTI.NewCallEventHandler(cti_onNewIncomingCall);
            cti.onNewOutgoingCall += new CTI.NewCallEventHandler(cti_onNewOutgoingCall);
        }

        void cti_onNewOutgoingCall(object sender, InfosAppel e)
        {
            if (onOutgoingCall != null)
            {
                onOutgoingCall(e.Caller, e.Callee);
            }
        }

        void cti_onNewIncomingCall(object sender, InfosAppel e)
        {
            if (onIncomingCall != null)
                onIncomingCall(e.Caller, e.Callee);
        }

        void cti_onCallDisconnected(object sender, InfosAppel e)
        {
            if (onDisconnected != null)
                onDisconnected((int)e.Duration);
        }

        void cti_onCallConnected(object sender, InfosAppel e)
        {
            if (onConnected != null)
                onConnected();
        }

        public void startMonitoring()
        {
            if (cti.IsMonitoring)
                cti.monitoringStop();
            while (!cti.monitoringStart())
                cti.configuration();
            ligne = cti.getMonitoredLines()[0];
        }

        public void stopMonitoring()
        {
            cti.monitoringStop();
        }

        public void showConfiguration()
        {
            cti.configuration();
        }

        public void dial(string number)
        {
            cti.dial(ligne, number);
        }

        public void disconnect()
        {
            cti.disconnect(ligne);
        }

        public void answer()
        {
            cti.answer(ligne);
        }

        public void blindTransfer(string numero)
        {
            cti.blindTransfer(ligne, numero);
        }


        
    }
}



les fonctions marchent parfaitement (dans navision ou excel par exemple)
par contre les evenements ne sont pas levé
je ne comprend pas pourquoi...

quelqu'un à une idée?

merci d'avance
warenbe

la société de consommation porte mal son nom car un con fait rarement une sommation avant de dire une connerie en société

1 réponse

warenbe Messages postés 145 Date d'inscription dimanche 2 décembre 2001 Statut Membre Dernière intervention 10 septembre 2009
10 sept. 2009 à 17:21
j'ajoute une précision:

j'aimerai fair fonctionner mon objet com avec NAVISION

voici ce que dit la doc navision sur les events


Event Triggers
The following information is useful when you have enabled C/SIDE to receive events from a component that it controls, for example, an automation server.
There are certain limitations on the triggers that are automatically generated for the events, which the component provides. Furthermore, incoming data is subject to certain restrictions.
Limitations
• C/SIDE only supports the default outgoing, that is, source interfaces, which are defined by the automation variable. If more than one outgoing interface is defined by the automation server for a coclass, only event triggers for the default outgoing interface are generated in the C/AL code.
• There can be a maximum of 39 parameters in function calls.
• There can be a maximum of 1024 characters in prototype text strings for functions.
• The connectable object strategy in COM is used to connect Microsoft Dynamics NAV and the automation server. The Sink object defined in this strategy and implemented in Microsoft Dynamics NAV only supports the IDispatch interface (and IUnknown). It is therefore expected that the automation server calls on IDispatch when executing events.
• Parameter names will be truncated to a maximum of 30 characters.
• There are no return values on event triggers.
• The variable name along with "::" and the event trigger name will be truncated to a maximum of 30 characters.
Restrictions on Incoming Data
All received data are copied to an internal data type, which can handle any data type that COM allows. No data is lost in this conversion and there is no check for valid AL data types.
The data will remain in this internal data type until it is used inside the trigger. When data is used, it is converted to the appropriate C/AL data type. Note, however, that if the data type is Variant, no conversion occurs. No data is lost in the conversion and all the required checks are made. If the conversion is not possible because there is an invalid data type, or because data is outside the range, the event trigger causes an error message to pop up and terminates execution. Note that if data is never used in the event trigger, no checks for valid data, data type and data range are performed.
If parameter is a VAR parameter (that is, called ByRef) and data is used inside the event trigger, there will be an implicit conversion just before the event trigger returns. A check is made of whether conversion is possible. If this is not the case, an error message is shown and the event trigger terminates.


des fois que ça vous donne des idées...



la société de consommation porte mal son nom car un con fait rarement une sommation avant de dire une connerie en société
0
Rejoignez-nous