Ejemplo n.º 1
0
        public bool SetConfiguration(TAPIAccountConfig objAccount, ref string registrationMsg)
        {
            bool rtn = true;

            try
            {
                IEnumerable <string> lines = objAccount.Line.SplitTo <string>(new char[] { ',' });

                if (lines.Count() == 0)
                {
                    rtn = false;
                }
                else
                {
                    IEnumAddress ea = tobj.EnumerateAddresses();
                    //txtLineName.Text = ">> " + line;

                    uint         arg3      = 0;
                    ITAddress    ln        = null;
                    ITCollection addresses = (ITCollection)tobj.Addresses;
                    string       success   = "Success : [ ";
                    string       failed    = "Failed : [ ";

                    int cnt = addresses.Count;

                    for (int i = 0; i < cnt; i++)
                    {
                        try
                        {
                            ea.Next(1, out ln, ref arg3);

                            if (ln != null && lines.Contains(ln.AddressName))
                            {
                                tobj.RegisterCallNotifications(ln, true, true, TapiConstants.LINEADDRESSTYPE_DOMAINNAME, 2);
                                success += ln.AddressName + ",";
                            }
                        }
                        catch (Exception ex)
                        {
                            failed += ln.AddressName + ",";
                            continue;
                        }
                    }



                    char[] trimChar = new char[] { ',' };
                    registrationMsg = success.TrimEnd(trimChar).Insert(success.Length - 1, " ]") + "|" +
                                      failed.TrimEnd(trimChar).Insert(failed.Length - 1, " ]");
                }
            }
            catch (Exception ein)
            {
                rtn = false;
            }

            return(rtn);
        }
Ejemplo n.º 2
0
        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            bool found = false;

            tapi = new TAPIClass();
            tapi.Initialize();

            call_notify           = new callnotification();
            call_notify.addtolist = new callnotification.listshow(this.status);
            tapi.ITTAPIEventNotification_Event_Event += new TAPI3Lib.ITTAPIEventNotification_EventEventHandler(call_notify.Event);
            tapi.EventFilter = (int)(TAPI_EVENT.TE_CALLNOTIFICATION |
                                     TAPI_EVENT.TE_DIGITEVENT |
                                     TAPI_EVENT.TE_PHONEEVENT |
                                     TAPI_EVENT.TE_CALLSTATE |
                                     TAPI_EVENT.TE_GENERATEEVENT |
                                     TAPI_EVENT.TE_GATHERDIGITS |
                                     TAPI_EVENT.TE_REQUEST);


            ITCollection          collec;
            ITAddress             address;
            ITMediaSupport        support;
            ITAddressCapabilities capability;

            collec = (ITCollection)tapi.Addresses;
            foreach (ITAddress addr in collec)
            {
                found      = false;
                address    = addr;
                support    = (ITMediaSupport)address;
                capability = (ITAddressCapabilities)address;
                if (support.QueryMediaType(TapiConstants.TAPIMEDIATYPE_AUDIO))
                {
                    found = true;
                }
                capability = null;
                support    = null;
                address    = null;
                if (found == true)
                {
                    if (addr.AddressName.ToUpper() == "H323 LINE")
                    {
                        call_address = addr;
                    }
                    //break;
                }
            }

            ////registration part
            registration = tapi.RegisterCallNotifications(call_address, true, true, TapiConstants.TAPIMEDIATYPE_AUDIO, 1);
        }