Esempio n. 1
0
        static void Bootstrap(string filePath, string[] args)
        {
            {
                var a = new Random(Environment.TickCount);
                //unique name PhoneSystem.ApplicationName = "TestApi";//any name
                PhoneSystem.ApplicationName = PhoneSystem.ApplicationName + a.Next().ToString();
            }

            #region phone system initialization(init db server)
            var value = Utilities.GetKeyValue("ConfService", "ConfPort", filePath);
            var port  = 0;
            PhoneSystem.CfgServerHost = "127.0.0.1";
            if (!string.IsNullOrEmpty(value))
            {
                int.TryParse(value.Trim(), out port);
                PhoneSystem.CfgServerPort = port;
            }
            value = Utilities.GetKeyValue("ConfService", "confUser", filePath);
            if (!string.IsNullOrEmpty(value))
            {
                PhoneSystem.CfgServerUser = value;
            }
            value = Utilities.GetKeyValue("ConfService", "confPass", filePath);
            if (!string.IsNullOrEmpty(value))
            {
                PhoneSystem.CfgServerPassword = value;
            }
            #endregion
            var dns = PhoneSystem.Root.GetDN(); //Access PhoneSystem.Root to initialize ObjectModel
            SampleStarter.StartSample(args);
            PhoneSystem.Root.Disconnect();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            {
                Random a = new Random(Environment.TickCount);
                //unique name PhoneSystem.ApplicationName = "TestApi";//any name
                PhoneSystem.ApplicationName = PhoneSystem.ApplicationName + a.Next().ToString();
            }

            #region phone system initialization(init db server)

            String _appPath = Utilities.GetAppPath();
            String filePath = Path.Combine(_appPath, @"Bin\3CXPhoneSystem.ini");
            String value    = Utilities.GetKeyValue("ConfService", "ConfPort", filePath);
            Int32  port     = 0;
            if (!String.IsNullOrEmpty(value))
            {
                Int32.TryParse(value.Trim(), out port);
                PhoneSystem.CfgServerPort = port;
            }
            value = Utilities.GetKeyValue("ConfService", "confUser", filePath);
            if (!String.IsNullOrEmpty(value))
            {
                PhoneSystem.CfgServerUser = value;
            }
            value = Utilities.GetKeyValue("ConfService", "confPass", filePath);
            if (!String.IsNullOrEmpty(value))
            {
                PhoneSystem.CfgServerPassword = value;
            }
            #endregion
            DN[] ps = PhoneSystem.Root.GetDN(); //Access PhoneSystem.Root to initialize ObjectModel
            SampleStarter.StartSample(args);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            try
            {
                {
                    Random a = new Random(Environment.TickCount);
                    //unique name PhoneSystem.ApplicationName = "TestApi";//any name
                    PhoneSystem.ApplicationName = PhoneSystem.ApplicationName + a.Next().ToString();
                }

                #region phone system initialization(init db server)
                String filePath = @".\3CXPhoneSystem.ini";
                if (!File.Exists(filePath))
                {
                    //this code expects 3CXPhoneSystem.ini in current directory.
                    //it can be taken from the installation folder (find it in Program Files/3CXPhone System/instance1/bin for in premiss installation)
                    //or this application can be run with current directory set to location of 3CXPhoneSystem.ini

                    //v14 (cloud and in premiss) installation has changed folder structure.
                    //3CXPhoneSystem.ini which contains connectio information is located in
                    //<Program Files>/3CX Phone System/instanceN/Bin folder.
                    //in premiss instance files are located in <Program Files>/3CX Phone System/instance1/Bin
                    throw new Exception("Cannot find 3CXPhoneSystem.ini");
                }
                String value = Utilities.GetKeyValue("ConfService", "ConfPort", filePath);
                Int32  port  = 0;
                if (!String.IsNullOrEmpty(value))
                {
                    Int32.TryParse(value.Trim(), out port);
                    PhoneSystem.CfgServerPort = port;
                }
                value = Utilities.GetKeyValue("ConfService", "confUser", filePath);
                if (!String.IsNullOrEmpty(value))
                {
                    PhoneSystem.CfgServerUser = value;
                }
                value = Utilities.GetKeyValue("ConfService", "confPass", filePath);
                if (!String.IsNullOrEmpty(value))
                {
                    PhoneSystem.CfgServerPassword = value;
                }
                #endregion
                DN[] ps = PhoneSystem.Root.GetDN(); //Access PhoneSystem.Root to initialize ObjectModel
                SampleStarter.StartSample(args);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Esempio n. 4
0
        static void Bootstrap(string[] args)
        {
            PhoneSystem.CfgServerHost     = "127.0.0.1";
            PhoneSystem.CfgServerPort     = int.Parse(iniContent["ConfService"]["ConfPort"]);
            PhoneSystem.CfgServerUser     = iniContent["ConfService"]["confUser"];
            PhoneSystem.CfgServerPassword = iniContent["ConfService"]["confPass"];
            var ps = PhoneSystem.Reset(
                PhoneSystem.ApplicationName + new Random(Environment.TickCount).Next().ToString(),
                "127.0.0.1",
                int.Parse(iniContent["ConfService"]["ConfPort"]),
                iniContent["ConfService"]["confUser"],
                iniContent["ConfService"]["confPass"]);

            ps.WaitForConnect(TimeSpan.FromSeconds(30));
            try
            {
                SampleStarter.StartSample(args);
            }
            finally
            {
                ps.Disconnect();
            }
        }