Пример #1
0
        [Test] public void RegisterFromAnotherThread()
        {
            AsyncProcessor processor = new AsyncProcessor(true);

            using ( processor )
            {
                RegisterProtocolHandler handler = new RegisterProtocolHandler(_manager, _plugin);
                processor.RunJob(handler);
                if (handler.Exception != null)
                {
                    throw handler.Exception;
                }
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            //If the program is executed with admin rights, we register the protocol handler
            var principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
            bool isAdmin = principal.IsInRole(WindowsBuiltInRole.Administrator);

            if (isAdmin)
            {
                var r = new RegisterProtocolHandler();
                r.Register();
                return;
            }

            Init();
            CheckSettings();

            string phoneNumber = null;
            if (args.Length > 0)
                phoneNumber = args[0];

            if (phoneNumber == null)
            {
                Console.Write("Please enter the phone number: ");
                phoneNumber = Console.ReadLine();
                Console.WriteLine();
            }

            if (phoneNumber == null)
                throw new ArgumentException("No phone number entered");

            if (phoneNumber.Length > 50)
                throw new ArgumentException("Phone number is too long");

            Console.WriteLine("Sent phone number '{0}'", phoneNumber);

            phoneNumber = Regex.Replace(phoneNumber, @"\+", "00"); //Placetel can't handel the + in the beginning
            phoneNumber = Regex.Replace(phoneNumber, @"[^0-9]", ""); //Strip all non number characters from the number.

            Console.WriteLine("Dialing the phone number '{0}'", phoneNumber);

            //Make the call
            var client = new PlacetelApiClient.PlacetelClient(_dialerConfig.ApiKey);
            client.InitiateCall(_dialerConfig.SipUser, phoneNumber);

            System.Threading.Thread.Sleep(3000);
        }