Exemplo n.º 1
0
        public void Run(params string[] args)
        {
            String command_name = args[1];
            Dictionary <String, String> parameters = new Dictionary <String, String>();

            for (int i = 2; i < args.Length; i++)
            {
                String[] a = args[i].Split(new char[] { '=' });
                if (a.Length >= 2)
                {
                    parameters.Add(a[0], String.Join("=", a, 1, a.Length - 1));
                }
                else
                {
                    System.Console.WriteLine(args[i] + " ignored");
                }
            }

            PBXConnection pbx = Utilities.CreatePbxConn();

            try
            {
                pbx.InvokeCommand(command_name, parameters);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var log      = GetProductionLogger();
            var assembly = System.Reflection.Assembly.GetExecutingAssembly();
            var fvi      = FileVersionInfo.GetVersionInfo(assembly.Location);
            var c        = new RealClock();

            log.LogInformation($"Starting PBXConnector Console Runner {fvi.FileVersion}");

            RegistryConfigurationProvider config;

            try {
                config = new RegistryConfigurationProvider(log);
            }
            catch (Exception ex) {
                log.LogError("Error starting PBXConnector Console Runner", ex);
                throw;
            }
            var ac = new ApplicationClient(
                new PBXApplicationClientConfigurationProvider(config),
                log, "CJASDBYCOKYIWBWNFPQHOBGIQPEJUBSYNEOUEKJZTOSWWCPGCRWNYGBOOUZE");
            var connector = new PBXConnection(log, config, ac, c);

            connector.Start();
        }
Exemplo n.º 3
0
        public void Run(params string[] args)
        {
            PBXConnection pbx = Utilities.CreatePbxConn();
            //in sample, we take first available connection of the specified extension.
            ActiveConnection ac = PhoneSystem.Root.GetDNByNumber(args[2]).GetActiveConnections()[0];

            pbx.BargeinCall(args[1], ac, PBXConnection.BargeInMode.BargeIn);
        }
Exemplo n.º 4
0
        public void Run(params string[] args)
        {
            Extension e = PhoneSystem.Root.GetDNByNumber(args[2]) as Extension;

            if (e != null)
            {
                PBXConnection pbx = Utilities.CreatePbxConn();
                pbx.Listen(System.Convert.ToInt32(args[1]), args[2]);
            }
        }
Exemplo n.º 5
0
        public void Run(params string[] args)
        {
            //args[1] - DN of external line
            DN dn = PhoneSystem.Root.GetDNByNumber(args[1]);

            if (dn is ExternalLine && (dn as ExternalLine).Gateway is VoipProvider)
            {
                PBXConnection pbxConnn = Utilities.CreatePbxConn();
                pbxConnn.RefreshRegistration(dn.Number);
            }
            else
            {
                Console.WriteLine(args[1] + " is not external line or not a VoipProvider line");
            }
        }
Exemplo n.º 6
0
        public void Run(params string[] args)
        {
            DN            dn    = PhoneSystem.Root.GetDNByNumber(args[1]);
            bool          found = false;
            PBXConnection pbx   = Utilities.CreatePbxConn();

            foreach (var ac in dn.GetActiveConnections())
            {
                pbx.DropCall(ac);
                found = true;
            }
            if (!found)
            {
                Console.WriteLine(args[2] + " does not participate in call " + args[1]);
            }
        }
Exemplo n.º 7
0
        public void Run(params string[] args)
        {
            PBXConnection pbx             = Utilities.CreatePbxConn();
            Dictionary <String, String> d = new Dictionary <String, String>();

            for (int i = 2; i < args.Length; i++)
            {
                String[] a = args[i].Split(new char[] { '=' });
                d.Add(a[0], a[1]);
            }
            try
            {
                pbx.MakeCall(args[1], d);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            }
        }
Exemplo n.º 8
0
        public void Run(params string[] args)
        {
            PBXConnection pbx = Utilities.CreatePbxConn();

            for (; ;)
            {
                try
                {
                    pbx.MakeCall(args[1], args[2]);
                }
                catch (Exception e)
                {
                    System.Console.WriteLine(e.ToString());
                }
                ConsoleKeyInfo k = System.Console.ReadKey(false);
                if (k.KeyChar == 'e')
                {
                    break;
                }
            }
        }
        protected override void OnStart(string[] args)
        {
            var assembly = System.Reflection.Assembly.GetExecutingAssembly();
            var fvi      = FileVersionInfo.GetVersionInfo(assembly.Location);

            _log.LogInformation($"Starting PBXConnector service {fvi.FileVersion}");

            try {
                _config = new RegistryConfigurationProvider(_log);
            } catch (Exception ex) {
                _log.LogError($"Error starting PBXConnectorService: {ex}");
                throw;
            }
            _log.LogInformation($"Completed Configuration Read");

            _ac = new ApplicationClient(new PBXApplicationClientConfigurationProvider(_config),
                                        _log, "CJASDBYCOKYIWBWNFPQHOBGIQPEJUBSYNEOUEKJZTOSWWCPGCRWNYGBOOUZE");
            _connection = new PBXConnection(_log, _config, _ac, _c);
            _log.LogInformation("Initialized PBX Connection Object");
            _connection.Start();
        }
Exemplo n.º 10
0
        public void Run(params string[] args)
        {
            DN dn = PhoneSystem.Root.GetDNByNumber(args[2]);

            ActiveConnection[] conns = dn.GetActiveConnections();
            bool found = false;

            foreach (ActiveConnection ac in conns)
            {
                if (ac.CallID == int.Parse(args[1]) && ac.Status == ConnectionStatus.Connected)
                {
                    PBXConnection pbx = Utilities.CreatePbxConn();
                    pbx.RecordCall(System.Convert.ToInt32(args[1]), args[2], System.Convert.ToInt32(args[3]) != 0);
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                Console.WriteLine(args[2] + " does not participate in call " + args[1] + " or call is in incorrect state");
            }
        }
Exemplo n.º 11
0
        public void Run(params string[] args)
        {
            PhoneSystem ps  = PhoneSystem.Root;
            IVR         ivr = ps.GetDNByNumber(args[1]) as IVR;
            Extension   ext = ps.GetDNByNumber(args[2]) as Extension;
            String      filename;

            if (ivr == null || ivr.GetActiveConnections().Length != 0)
            {
                Console.WriteLine("ERROR: IVR " + args[1] + " does not exist or currently active");
                return;
            }

            if (ext == null || !ext.IsRegistered || ext.GetActiveConnections().Length != 0)
            {
                Console.WriteLine("ERROR: Extension " + args[2] + " does not exist, is busy or is not registered");
                return;
            }
            bool checkUpdateOfFile = false;

            if (args.Length < 4)
            {
                filename = Path.GetFileNameWithoutExtension(ivr.PromptFilename).ToLowerInvariant();
            }
            else
            {
                filename = args[3].ToLowerInvariant();
            }
            String fileNameToRecord = Path.Combine(ps.GetParameterByName("IVRPROMPTPATH").Value, filename + ".wav");

            if (args.Length > 3 && File.Exists(fileNameToRecord) && Path.GetFileNameWithoutExtension(ivr.PromptFilename).ToLowerInvariant() != filename)
            {
                Console.WriteLine("ERROR: File already exist but not selected for IVR:" + ivr.Number + "(" + ivr.Name + ")");
                return;
            }
            DateTime filedt = DateTime.UtcNow;

            if (File.Exists(fileNameToRecord))
            {
                checkUpdateOfFile = true;
                filedt            = File.GetLastWriteTimeUtc(fileNameToRecord);
            }


            Dictionary <String, String> a = new Dictionary <string, string>();

            a["extension"] = args[2];
            a["filename"]  = fileNameToRecord;
            PBXConnection pbx = Utilities.CreatePbxConn();

            pbx.MakeCall("RecordFile", a);
            Console.Write("Wait for the call.");
            for (int i = 0; i < 20 && ext.GetActiveConnections().Length == 0; i++)
            {
                Console.Write(".");
                Thread.Sleep(1000);
            }
            if (ext.GetActiveConnections().Length == 0)
            {
                Console.WriteLine("FAILED");
                return;
            }
            Console.WriteLine("Done");
            Console.Write("Wait for the end of the call.");
            while (ext.GetActiveConnections().Length > 0)
            {
                Console.Write(".");
                Thread.Sleep(1000);
            }
            Console.WriteLine("Done");
            if (checkUpdateOfFile)
            {
                Console.Write("Waiting for file update.");
                for (int i = 0; i < 20 && File.GetLastWriteTimeUtc(fileNameToRecord) == filedt; i++)
                {
                    Console.Write(".");
                    Thread.Sleep(1000);
                }
                if (File.GetLastWriteTimeUtc(fileNameToRecord) == filedt)
                {
                    Console.WriteLine("FAILED");
                    return;
                }
                else
                {
                    Console.WriteLine("Done");
                }
            }
            else
            {
                Console.Write("Waiting for new file.");
                for (int i = 0; i < 20 && !File.Exists(fileNameToRecord); i++)
                {
                    Console.Write(".");
                    Thread.Sleep(1000);
                }

                if (!File.Exists(fileNameToRecord))
                {
                    Console.WriteLine("FAILED");
                    return;
                }
                else
                {
                    Console.WriteLine("Done");
                }
            }
            ivr.PromptFilename = filename + ".wav";
            ivr.Save();
            Console.WriteLine("Prompt successfuly changed on IVR:" + ivr.Number + "(" + ivr.Name + ")");
        }
Exemplo n.º 12
0
        public void Run(params string[] args)
        {
            PBXConnection pbx = Utilities.CreatePbxConn();

            pbx.BargeinCall(System.Convert.ToInt32(args[1]), args[2], false);
        }