IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Forms Discussion :

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


Sujet :

Windows Forms

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    46
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 46
    Points : 36
    Points
    36
    Par défaut Evenements dans un objet COM réalisé en c#
    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:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
     
    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

  2. #2
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    46
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2005
    Messages : 46
    Points : 36
    Points
    36
    Par défaut
    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...

Discussions similaires

  1. Utiliser objet COM Flash dans dll C#
    Par julianito1 dans le forum C#
    Réponses: 6
    Dernier message: 24/05/2011, 09h44
  2. charger objet Com dans une page web
    Par psycho_xn dans le forum Général Dotnet
    Réponses: 18
    Dernier message: 12/11/2009, 17h55
  3. Réponses: 1
    Dernier message: 17/04/2009, 17h56
  4. [COM] Gestion d'events contenus dans un objet COM
    Par Marmottoc dans le forum Delphi
    Réponses: 1
    Dernier message: 19/05/2006, 14h43
  5. [POO] débutante dans les objets COM
    Par SandraG dans le forum Langage
    Réponses: 11
    Dernier message: 16/03/2006, 12h03

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo